summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Beich <jbeich@FreeBSD.org>2023-12-02 00:21:20 +0100
committerJan Beich <jbeich@FreeBSD.org>2023-12-02 00:25:50 +0100
commit01d3e250ab41622742ccb5bf93819ae364a65310 (patch)
tree1d43da86096a9d5f429ef1869c0ff7cfa02a8d46
parenthost_memory: allow missing MAP_NORESERVE on FreeBSD after 448d4815dece (diff)
downloadyuzu-01d3e250ab41622742ccb5bf93819ae364a65310.tar
yuzu-01d3e250ab41622742ccb5bf93819ae364a65310.tar.gz
yuzu-01d3e250ab41622742ccb5bf93819ae364a65310.tar.bz2
yuzu-01d3e250ab41622742ccb5bf93819ae364a65310.tar.lz
yuzu-01d3e250ab41622742ccb5bf93819ae364a65310.tar.xz
yuzu-01d3e250ab41622742ccb5bf93819ae364a65310.tar.zst
yuzu-01d3e250ab41622742ccb5bf93819ae364a65310.zip
-rw-r--r--src/common/host_memory.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp
index 179f6ab11..4bfc64f2d 100644
--- a/src/common/host_memory.cpp
+++ b/src/common/host_memory.cpp
@@ -408,6 +408,16 @@ static void* ChooseVirtualBase(size_t virtual_size) {
#else
static void* ChooseVirtualBase(size_t virtual_size) {
+#if defined(__FreeBSD__)
+ void* virtual_base =
+ mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_ALIGNED_SUPER, -1, 0);
+
+ if (virtual_base != MAP_FAILED) {
+ return virtual_base;
+ }
+#endif
+
return mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);
}
@@ -463,24 +473,12 @@ public:
}
// Virtual memory initialization
-#if defined(__FreeBSD__)
- virtual_base =
- static_cast<u8*>(mmap(nullptr, virtual_size, PROT_NONE,
- MAP_PRIVATE | MAP_ANONYMOUS | MAP_ALIGNED_SUPER, -1, 0));
- if (virtual_base == MAP_FAILED) {
- virtual_base = static_cast<u8*>(
- mmap(nullptr, virtual_size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
- if (virtual_base == MAP_FAILED) {
- LOG_CRITICAL(HW_Memory, "mmap failed: {}", strerror(errno));
- throw std::bad_alloc{};
- }
- }
-#else
virtual_base = virtual_map_base = static_cast<u8*>(ChooseVirtualBase(virtual_size));
if (virtual_base == MAP_FAILED) {
LOG_CRITICAL(HW_Memory, "mmap failed: {}", strerror(errno));
throw std::bad_alloc{};
}
+#if defined(__linux__)
madvise(virtual_base, virtual_size, MADV_HUGEPAGE);
#endif